//
//  SettingsDatabase.m
//  MantuPlay
//
//  Created by Markus Sintonen on 4.10.2009.
//  Copyright 2009 __MyCompanyName__. All rights reserved.
//

#import "SettingsDatabase.h"


@implementation SettingsDatabase

@synthesize trackScanningDirectories, applicationSettingsFolder, albumArtFolder;

SINGLETON_IMPLEMENTATION(SettingsDatabase, sharedSettingsDatabase)

-(id)init {
	if ((self = [super init]) != nil) {
		[self setupSettingsDatabase];
	}
	return self;
}

-(void)setupSettingsDatabase {
	trackScanningDirectories = [[NSArray alloc] initWithObjects:@"/private/var/mobile/Media/iTunes_Control/Music", nil];
	
	applicationSettingsFolder = [[NSString alloc] initWithString:[[NSSearchPathForDirectoriesInDomains(NSLibraryDirectory,NSUserDomainMask,YES) objectAtIndex:0] stringByAppendingPathComponent:@"MantuPlay"]];
	albumArtFolder = [[NSString alloc] initWithString:[applicationSettingsFolder stringByAppendingPathComponent:@"AlbumArt"]];
	
	NSFileManager *fileManager = [NSFileManager defaultManager];
	if(![fileManager fileExistsAtPath:applicationSettingsFolder]) {
		[fileManager createDirectoryAtPath:applicationSettingsFolder attributes:nil];
	}
	if(![fileManager fileExistsAtPath:albumArtFolder]) {
		[fileManager createDirectoryAtPath:albumArtFolder attributes:nil];
	}
}

-(NSArray*)trackScanningDirectories {
	return trackScanningDirectories;
}
-(NSString*)applicationSettingsFolder {
	return applicationSettingsFolder;
}
-(NSString*)albumArtFolder {
	return albumArtFolder;
}

- (void)dealloc {
	[trackScanningDirectories release];
	[applicationSettingsFolder release];
	[albumArtFolder release];
	[super dealloc];
}
@end
